12-10-2020
Układ współrzędnych (coord): ramy, w których osadzona jest historia.
df = data.frame(x = c(0,1,2), y = c(5,6,7))
p1 <- ggplot(df, aes(x=x, y=y)) +
xlab("") +
ylab("")
p2 <- ggplot(df, aes(x=x, y=y)) +
xlab("") +
ylab("") +
coord_flip()
p1 + p2
Dane (data): tabela, w której obserwacje opisane są przez wektor chech.
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species ## 1 5.1 3.5 1.4 0.2 setosa ## 2 4.9 3.0 1.4 0.2 setosa ## 3 4.7 3.2 1.3 0.2 setosa ## 4 4.6 3.1 1.5 0.2 setosa ## 5 5.0 3.6 1.4 0.2 setosa ## 6 5.4 3.9 1.7 0.4 setosa
Mapowania (aes): pary cech obserwacji i atrybutów wykresu.
p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point(size = 4) p2 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + geom_point(size = 4) p3 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Sepal.Length)) + geom_point(size = 4) p4 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, shape = Species)) + geom_point(size = 4) (p1 + p2) / (p3 + p4)
Formy (geom): graficzna reprezentacja wartości liczbowych.
Formy (geom): graficzna reprezentacja wartości liczbowych.
p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + geom_point(size = 4) p2 <- ggplot(iris, aes(x = Species, y = Sepal.Length)) + stat_summary(fun.y = "mean", geom = "bar") p3 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + geom_line() p4 <- ggplot(iris, aes(x = Species, y = Sepal.Length, color = Species)) + geom_boxplot() (p1 + p2) / (p3 + p4)
Statystyki (stat): agregaty danych
Statystyki (stat): agregaty danych
p1 <- ggplot(iris, aes(x = Sepal.Length, fill = Species)) + geom_density(alpha = 0.5) p2 <- ggplot(iris, aes(x = Species, y = Sepal.Length, color = Species)) + geom_boxplot() p3 <- ggplot(iris, aes(x = Species, y = Sepal.Length, color = Species)) + geom_violin() p4 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, fill = Species)) + stat_density2d(aes(alpha = ..level..), geom = "polygon", color = "black") (p1 + p2) / (p3 + p4)
Przesunięcia (position): modyfikatory położenia.
Przesunięcia (position): modyfikatory położenia.
p1 <- ggplot(iris, aes(x = Species, y = Sepal.Length, color = Species)) + geom_jitter(position = "identity")+ theme(legend.position = "bottom") p2 <- ggplot(iris, aes(x = Species, y = Sepal.Length, color = Species)) + geom_jitter(position = "jitter") + theme(legend.position = "bottom") (p1 + p2)
Panele (facets): fragmenty historii o teh samej strukturze dla podzbiorów danych.
Skale (scale): transformacja cech obserwacji na atrybuty wykresu.
p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() p2 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() + scale_x_reverse() p1 + p2
Dekoracje (theme): styl wizualny.
Dekoracje (theme): styl wizualny.
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species, shape = Species)) +
geom_point(size = 4) +
theme_economist() +
ggtitle("Theme: economist")
Dekoracje (theme): styl wizualny.
Dekoracje (theme): styl wizualny.
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species, shape = Species)) +
geom_point(size = 4) +
theme_tufte() +
ggtitle("Theme: Tufte")
Dekoracje (theme): styl wizualny.
Dekoracje (theme): styl wizualny.
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species, shape = Species)) +
geom_point(size = 4) +
theme_excel() +
ggtitle("Theme: Excel")